/**
 * @description  Barra（归因分析）
 * @author shenhong
 */
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Row, Col } from 'antd';
import { FirstHeaderC, PrimaryGhostC, SecondHeaderC } from '../../../../comps';
import DecomposeIncome from '../publicComponent/decomposeIncome'; // 收益分解
import ExcessTrend from '../publicComponent/excessTrend'; // 超额趋势
import FactorYield from './factorYield'; // 因子收益率
import FactorExposure from './factorExposure'; // 因子暴露度&市值
import FactorIncomeContribution from './factorIncomeContribution'; // 因子收益贡献
import { exportFile } from '@/src/utils/commonFunc';

class Barra extends PureComponent {
  constructor() {
    super();
    this.state = {};
  }

  export = () => {
    const { args } = this.props;
    exportFile('thfx/barra/downloadFactorContributionDetail/', args);
  };

  render() {
    const { args } = this.props;

    return (
      <div style={{ marginTop: '20px' }}>
        <SecondHeaderC title='归因概览' />
        <div style={{ marginBottom: '20px' }}>
          <Row gutter={16}>
            <Col span={12}>
              <DecomposeIncome args={args} />
            </Col>
            <Col span={12}>
              <ExcessTrend args={args} />
            </Col>
          </Row>
        </div>
        <SecondHeaderC title='因子收益率' />
        <div style={{ marginBottom: '20px' }}>
          <FactorYield args={args} />
        </div>
        <SecondHeaderC title='因子暴露度' />
        <div style={{ marginBottom: '20px' }}>
          <FactorExposure args={args} />
        </div>
        <SecondHeaderC
          title='因子收益贡献'
          Right={
            <PrimaryGhostC
              title='导出'
              // style={{ margin: '10px', float: 'right' }}
              onClick={this.export}
            />
          }
        />
        <div style={{ marginBottom: '20px' }}>
          <FactorIncomeContribution args={args} />
        </div>
      </div>
    );
  }
}
export default connect(({ attributionAnalysisM }) => ({
  attributionAnalysisM,
}))(Barra);
